/**
* @Title: SimpleChatServerInitializer.java
* @Package com.an.simplechat
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com
* @date 2017年7月21日 上午9:30:31
* @version V1.0
*/


package com.an.simplechat;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

/**
* @ClassName: SimpleChatServerInitializer
* @Description: TODO(服务端初始化类，用来增加多个处理器类到ChannelPipleline上)
* @author antch,861710865@qq.com
* @date 2017年7月21日 上午9:30:31
*
*/

public class SimpleChatServerInitializer extends ChannelInitializer<SocketChannel> {

	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		// TODO Auto-generated method stub
		ChannelPipeline pipeLine = ch.pipeline();

		pipeLine.addLast("framder",new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
		pipeLine.addLast("decoder",new StringDecoder());
		pipeLine.addLast("encoder",new StringEncoder());
		pipeLine.addLast("handler",new SimpleChatServerHandler());

		System.out.println("通道初始化。。。SimpleChatClient:" + ch.remoteAddress() + "连接上");
	}

}
